package com.hicoffee.bm.controller;


import com.hicoffee.bm.model.HeyCustomer;
import com.hicoffee.bm.service.HeyCustomerService;
import com.hicoffee.bm.utils.ResponseUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import com.radarwin.framework.web.controller.BaseController;
import com.radarwin.framework.web.response.ResponseWrapper;
import com.radarwin.framework.util.StringUtil;



/**
 *  auto generated by generation tools v1.0.0
 */
@Controller
@RequestMapping("/heyCustomer")
public class HeyCustomerController extends BaseController {



    @Autowired
    private HeyCustomerService heyCustomerService;




	@RequestMapping(value = "/pageList")
	@ResponseBody
	public ResponseWrapper getHeyCustomerPageList (HttpServletRequest request) {
		return heyCustomerService.getHeyCustomerPageList(convertParamToMap(request));
	}





    @RequestMapping(value = "/get")
    @ResponseBody
    public ResponseWrapper get(String id) {
        HeyCustomer heyCustomer = new HeyCustomer();
        if (StringUtil.isNotBlank(id)) {
           heyCustomer= heyCustomerService.selectByKey(id);
        }
        return ResponseUtil.successResponse("heyCustomer",heyCustomer);
    }

    @RequestMapping(value = "/add")
	@ResponseBody
	public ResponseWrapper create(HeyCustomer heyCustomer) {
        int result = heyCustomerService.insert(heyCustomer);
        if(result>0){
            return ResponseUtil.successResponse("新增成功");
        }
		return ResponseUtil.successResponse("新增失败");
	}


    @RequestMapping(value = "/update")
	@ResponseBody
	public ResponseWrapper update(HeyCustomer heyCustomer) {
		int result = heyCustomerService.update(heyCustomer);
        if(result>0){
            return ResponseUtil.successResponse("更新成功");
        }
        return ResponseUtil.successResponse("更新失败");
	}


	@RequestMapping(value = "/delete")
    @ResponseBody
    public ResponseWrapper delete(String ids) {
        HeyCustomer heyCustomer = new HeyCustomer();
        int result=0;
        if (StringUtil.isNotBlank(ids)) {
            heyCustomer.setId(Long.valueOf(ids));
            heyCustomer.setDeleted(true);
            result = heyCustomerService.update(heyCustomer);
        }
    	if(result>0){
            return ResponseUtil.errorResponse("删除成功");
        }
        return ResponseUtil.errorResponse("删除失败");
    }




}
